<?php

namespace app\admin\model\csmwj;

use think\Model;


class Userpaper extends Model
{

    

    

    // 表名
    protected $name = 'csmwj_userpaper';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'iseffectverison_text',
        'answerstatus_text',
        'submitmethod_text',
        'status_text'
    ];
    

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }

    
    public function getIseffectverisonList()
    {
        return ['Y' => __('Iseffectverison y'), 'N' => __('Iseffectverison n')];
    }

    public function getAnswerstatusList()
    {
        return ['DRAFT' => __('Answerstatus draft'), 'FINISH' => __('Answerstatus finish')];
    }

    public function getSubmitmethodList()
    {
        return ['MT' => __('Submitmethod mt'), 'AT8TIME' => __('Submitmethod at8time')];
    }

    public function getStatusList()
    {
        return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
    }


    public function getIseffectverisonTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['iseffectverison']) ? $data['iseffectverison'] : '');
        $list = $this->getIseffectverisonList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getAnswerstatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['answerstatus']) ? $data['answerstatus'] : '');
        $list = $this->getAnswerstatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getSubmitmethodTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['submitmethod']) ? $data['submitmethod'] : '');
        $list = $this->getSubmitmethodList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
